package com.info.zhiduoduo.pay.sdk.dayspaysdk.model.pay.request;

import com.info.zhiduoduo.pay.sdk.dayspaysdk.constant.DaysApiTypeEnum;
import com.info.zhiduoduo.pay.sdk.dayspaysdk.core.util.DateUtil;
import com.info.zhiduoduo.pay.sdk.dayspaysdk.core.util.LocalSeqNo;
import com.info.zhiduoduo.pay.formbean.dayspay.DaysQueryAgentPayFormBean;

import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class QueryPayReqDTO {

	/** 服务代号	N	4	1	1	0300 */
	private String serviceCode; 	
	/** 处理码	N	6	1	1	参考5.1 */
	private String processCode; 	
	/** 版本号	AN	10	0	0	默认1.0.0 */
	private String version; 	
	/** 商户编号	N	15	1	1 */
	private String merchantNo; 	
	/** 商户订单编号	AN	30	0	1 */
	private String merchantOrderNo; 	
	/** 请求流水	AN	30	1	1	每笔请求不重复 */
	private String sequenceNo; 	
	/** 平台订单编号	AN	20	0	1 */
	private String orderNo; 	
	/** 下单日期	N	8	1	1	yyyyMMdd，默认当天 */
	private String orderDate; 	
	/** 报文签名信息	AN	1200	1	0 */
	private String signMsg;

	public static QueryPayReqDTO of(DaysQueryAgentPayFormBean formBean) {
		QueryPayReqDTO dto = new QueryPayReqDTO().setServiceCode(DaysApiTypeEnum.QUERY_AGENT_PAY.serviceCode)
				.setProcessCode(DaysApiTypeEnum.QUERY_AGENT_PAY.processCode)
				.setVersion("1.0.0")
				.setMerchantOrderNo(formBean.getTradeNo())
				.setSequenceNo(DateUtil.MMdd(new Date()) + LocalSeqNo.next(8))
				.setOrderNo(formBean.getPartnerOrderNo())
				.setOrderDate(DateUtil.yyyyMMdd(formBean.getTradetime()));
		return dto;
	}
}
